package com.lianxi.nmms.util;

import com.lianxi.nmms.constant.ProductConstant;
import com.lianxi.nmms.controller.ProductController;
import com.lianxi.nmms.dao.SequenceMapper;
import com.lianxi.nmms.entity.Sequence;
import com.lianxi.nmms.entity.SequenceExample;
import com.lianxi.nmms.exception.RequestParameterErrorException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 翔哥
 * 2025年09月28日
 */
public class ParameterUtil {


    public static boolean isNull(String s){
        return (null ==s || "".equals(s));
    }

    public static String getSequence(String value) throws RequestParameterErrorException {

        if(ProductConstant.PRODUCT_NO_MAX.equals(value)){
            return ProductConstant.PRODUCT_NO_MIN;
        }

        int i =Integer.valueOf(value)+1;
        String v ="00000"+i;

        return v.substring(v.length()-6);
    }

    //判断密码是否合规:只能有数字或字母
    public static boolean setPassword(String password) {
        if (password == null || password.isEmpty()) {
            return false;
        }
        return password.matches("[a-zA-Z0-9]+");
    }

    //判断电话号码是否合规:11位数字，1开头
    public static boolean setPhone(String phone) {
        if (phone == null || phone.length() != 11) {
            return false;
        }
        return phone.matches("1[0-9]{10}");
    }

    //判断邮箱是否合规:XXX@XXX.XXX
    public static boolean setEmail(String email) {
        if (email == null || email.isEmpty()) {
            return false;
        }
        return email.matches("[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z]+");
    }
}
